home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_351 / pdc / libsrc.lzh / LibSrc / Math / pml.h < prev    next >
C/C++ Source or Header  |  1990-04-07  |  5KB  |  133 lines

  1. /************************************************************************
  2.  *                                                                      *
  3.  *                              N O T I C E                             *
  4.  *                                                                      *
  5.  *                      Copyright Abandoned, 1987, Fred Fish            *
  6.  *                                                                      *
  7.  *      This previously copyrighted work has been placed into the       *
  8.  *      public domain by the author (Fred Fish) and may be freely used  *
  9.  *      for any purpose, private or commercial.  I would appreciate     *
  10.  *      it, as a courtesy, if this notice is left in all copies and     *
  11.  *      derivative works.  Thank you, and enjoy...                      *
  12.  *                                                                      *
  13.  *      The author makes no warranty of any kind with respect to this   *
  14.  *      product and explicitly disclaims any implied warranties of      *
  15.  *      merchantability or fitness for any particular purpose.          *
  16.  *                                                                      *
  17.  ************************************************************************
  18.  */
  19.  
  20. /*
  21.  *      This file gets included with all of the floating point math
  22.  *      library routines when they are compiled.  Note that
  23.  *      this is the proper place to put machine dependencies
  24.  *      whenever possible.
  25.  *
  26.  *      It should be pointed out that for simplicity's sake, the
  27.  *      environment parameters are defined as floating point constants,
  28.  *      rather than octal or hexadecimal initializations of allocated
  29.  *      storage areas.  This means that the range of allowed numbers
  30.  *      may not exactly match the hardware's capabilities.  For example,
  31.  *      if the maximum positive double precision floating point number
  32.  *      is EXACTLY 1.11...E100 and the constant "MAXDOUBLE is
  33.  *      defined to be 1.11E100 then the numbers between 1.11E100 and
  34.  *      1.11...E100 are considered to be undefined.  For most
  35.  *      applications, this will cause no problems.
  36.  *
  37.  *      An alternate method is to allocate a global static "double" variable,
  38.  *      say "maxdouble", and use a union declaration and initialization
  39.  *      to initialize it with the proper bits for the EXACT maximum value.
  40.  *      This was not done because the only compilers available to the
  41.  *      author did not fully support union initialization features.
  42.  *
  43.  */
  44.  
  45. #ifndef NO_DBUG
  46. #    include <dbug.h>
  47. #else
  48. #    define DBUG_ENTER(a1)
  49. #    define DBUG_RETURN(a1) return(a1)
  50. #    define DBUG_VOID_RETURN return
  51. #    define DBUG_EXECUTE(keyword,a1)
  52. #    define DBUG_2(keyword,format)
  53. #    define DBUG_3(keyword,format,a1)
  54. #    define DBUG_4(keyword,format,a1,a2)
  55. #    define DBUG_5(keyword,format,a1,a2,a3)
  56. #    define DBUG_PUSH(a1)
  57. #    define DBUG_POP()
  58. #    define DBUG_PROCESS(a1)
  59. #    define DBUG_FILE (stderr)
  60. #endif
  61.  
  62. #include <errno.h>
  63.  
  64. /*
  65.  *      MAXDOUBLE       =>      Maximum double precision number
  66.  *      MINDOUBLE       =>      Minimum double precision number
  67.  *      DMAXEXP         =>      Maximum exponent of a double
  68.  *      DMINEXP         =>      Minimum exponent of a double
  69.  */
  70.  
  71. #ifndef MINDOUBLE
  72. #define MINDOUBLE       (1.0/MAXDOUBLE) 
  73. #endif 
  74.  
  75. #define LOG2_MAXDOUBLE  (DMAXEXP + 1)
  76. #define LOG2_MINDOUBLE  (DMINEXP - 1)
  77. #define LOGE_MAXDOUBLE  (LOG2_MAXDOUBLE / LOG2E)
  78. #define LOGE_MINDOUBLE  (LOG2_MINDOUBLE / LOG2E)
  79.  
  80. /*
  81.  *      The following are hacks which should be fixed when I understand all
  82.  *      the issues a little better.   |tanh(TANH_MAXARG)| = 1.0
  83.  */
  84. #define TANH_MAXARG 16
  85. #define SQRT_MAXDOUBLE 1.304380e19
  86.  
  87. #define PI              3.14159265358979323846
  88. #define TWOPI           (2.0 * PI)
  89. #define HALFPI          (PI / 2.0)
  90. #define FOURTHPI        (PI / 4.0)
  91. #define SIXTHPI         (PI / 6.0)
  92. #define LOG2E           1.4426950408889634074   /* Log to base 2 of e */
  93. #define LOG10E          0.4342944819032518276
  94. #define SQRT2           1.4142135623730950488
  95. #define SQRT3           1.7320508075688772935
  96. #define LN2             0.6931471805599453094
  97. #define LNSQRT2         0.3465735902799726547
  98.  
  99.  
  100. /*
  101.  *      MC68000 HARDWARE DEPENDENCIES
  102.  *
  103.  *              cc -DIEEE       =>      uses IEEE floating point format
  104.  *
  105.  */
  106.  
  107. #define TRUE 1                  /* This really should be in stdio.h */
  108. #define FALSE 0                 /* This too */
  109. #define VOID void
  110.  
  111. struct exception {
  112.         int type;
  113.         char *name;
  114.         double arg1;
  115.         double arg2;
  116.         double retval;
  117. };
  118.  
  119.  
  120. #define DOMAIN          1
  121. #define SING            2
  122. #define OVERFLOW        3
  123. #define UNDERFLOW       4
  124. #define TLOSS           5
  125. #define PLOSS           6
  126.  
  127. #define MAX_ERRORS              8
  128.  
  129. #define LOG                             1
  130. #define COUNT                   2
  131. #define CONTINUE                4
  132.  
  133.